 require.config({
            baseUrl:"../",
               paths:{
               bsl:'bsl',
               
               }
               });
 require(['bsl'],function(bsl){
        document.addEventListener('deviceready', onDeviceready, false);
        function onDeviceready(){
        alert("accelerometer");
        
        
        
        function getCurrentAcce(){
        
        function onSuccess(acceleration) {
        alert('Acceleration X: ' + acceleration.x + '\n' +
              'Acceleration Y: ' + acceleration.y + '\n' +
              'Acceleration Z: ' + acceleration.z + '\n' +
              'Timestamp: '      + acceleration.timestamp + '\n');
        };
        function onError() {
        alert('onError!');
        };
         bsl.accelerometer.getCurrentAcceleration(onSuccess, onError);
        }
        
        var accelerationWatch;
        var acc = document.getElementById("mytext");
        function watchAcce(){
        accelerationWatch =bsl.accelerometer.watchAcceleration( function ( a ) {
                                                                     acc.innerText =  "x:" + a.x + "\ny:" + a.y + "\nz:" + a.z+"\nTimestamp: "      + a.timestamp + '\n';
                                                                     }, function ( e ) {
                                                                     alert( "Acceleration error: " + e.message );
                                                                     }, {frequency:1000} ); // 设置更新间隔时间为1s
        }
        
        function clearWatchAcce(){
        bsl.accelerometer.clearWatch(accelerationWatch);
        updateAcceleration({
                           x: "",
                           y: "",
                           z: ""
                           });
        accelerationWatch = null;
        
        }
        
        
        
        document.getElementById("getCurrentAcceleration").addEventListener("click",getCurrentAcce,false);
        document.getElementById("watchAcceleration").addEventListener("click",watchAcce,false);
        document.getElementById("clearWatch").addEventListener("click",clearWatchAcce,false);
        }
        
        
        
        
        
        
        });